<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('账号管理列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>用户账号：</label>
                                <input type="text" name="username"/>
                            </li>
                            <li>
                                <label>渠道：</label>
                                <input type="text" name="channelcode"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">

            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('system:account:edit')}]];
        var removeFlag = [[${@permission.hasPermi('system:account:remove')}]];
        var prefix = ctx + "system/account";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                stopUrl: prefix + "/stopUserName",
                modalName: "账号管理",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'id', 
                    title: 'sid',
                    visible: false
                },
                {
                    field: 'username', 
                    title: '用户账号'
                },
                {
                    field: 'channelcode', 
                    title: '渠道'
                },
                {
                    field: 'createtime', 
                    title: '创建时间'
                },
                {
                    field: 'isstop', 
                    title: '是否封停'
                },
                {
                    field: 'pwd', 
                    title: '密码'
                },
                {
                    field: 'privilege', 
                    title: '权限'
                },
                {
                    field: 'gold', 
                    title: '元宝'
                },
                {
                    field: 'isuse', 
                    title: '是否领取福利'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        if(row.isstop == 0){
                            actions.push(' <a class="btn btn-success btn-xs "  onclick=refreshCach(\''+row.username+"\',\'0\',\'sealPhone\'"+')>封禁账号</a>');

                        }else{
                            actions.push(' <a class="btn btn-success btn-xs "  onclick=refreshCach(\''+row.username+"\',\'1\',\'sealPhone\'"+')>解封账号</a>');
                        }

                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
    </script>
</body>
<script>
    function refreshCach (name,state,type) {
        var ctx = window.location.host;
        // 保存信息 刷新表格
            $.modal.confirm("确定封禁该账号吗吗？", function() {
                var url = prefix + "/stopUserName";
                var data = { "username": name,"isstop":state };
                var config = {
                    url: url,
                    type: "post",
                    dataType: "json",
                    data: data,
                    beforeSend: function () {
                        $.modal.loading("正在处理中，请稍后...");

                    },
                    success: function(result) {
                        if (typeof callback == "function") {
                            callback(result);
                        }
                        $.operate.ajaxSuccess(result);
                    }
                };
                var url = "/system/cacheManage/refreshCache";
                $.ajax(config)
                var config2 = {
                    url: url,
                    type: "post",
                    dataType: "json",
                    data: {"type":type,"value":name,"state":state},
                    beforeSend: function () {
                        $.modal.loading("正在处理中，请稍后...");
                    },
                    success: function(result) {
                        if (typeof callback == "function") {
                            callback(result);
                        }
                        $.operate.ajaxSuccess(result);
                    }
                };
                $.ajax(config2)
            });


    }


</script>
</html>